"use strict"
const mvc = require('cosjs.mvc');
const random = mvc.library.require('random');
/**
 * @name fWboss
 * 好友boss
 */

/**
 * @name openStar
 * @param int id starID
 * 点击流星召唤好友boss
 */
exports.openStar = async function () {
    let meteorID = this.get('id', 'int');//stageConfig['meteorGroup'];
    let fWboss = this.model.mongo('fWboss', this.sid);
    //判断role身上是否有这个流星
    this.updater.role.key('fWbossID');
    await this.updater.data();
    let fWbossID = this.updater.role.get('fWbossID') || 0;
    if (fWbossID != meteorID || fWbossID == 0) {
        return this.quick_error("m2sgrbs0", "流星ID不匹配", fWbossID, meteorID);
    }
    let meteorConfig = this.config("friendBossMeteor", meteorID);
    if (!meteorConfig) {
        return this.quick_error("m2sgrbs1", "流星配置不存在", meteorID);
    }
    let k = random.Relative(meteorConfig.bossList, 'val');
    if (k === false) {
        return this.quick_error("M7GHLB123", 'err request', k);
    }
    let bossConfig = this.config("friendBoss", meteorConfig.bossList[k].bossID);
    if (!bossConfig) {
        return this.quick_error("m2sgrbs2", "boss配置不存在", meteorConfig.bossList[k].bossID);
    }
    // this.updater.item.group(bossConfig.onhookBoxID, 1);
    let { err, ret } = this.library("item/group", bossConfig.onhookBoxID, 1);
    if (err) {
        return this.quick_error("m2sgrbs3", "奖励配置不存在", bossConfig.onhookBoxID);
    }
    // let _total_add = {};
    // if (Array.isArray(ret)) {
    //     for (let v in ret) {
    //         if (_total_add.hasOwnProperty(ret[v].id)) {
    //             _total_add[ret[v].id] += ret[v].num;
    //         } else {
    //             _total_add[ret[v].id] = ret[v].num;
    //         }
    //     }
    // } else {
    //     if (_total_add.hasOwnProperty(ret.id)) {
    //         _total_add[ret.id] += ret.num;
    //     } else {
    //         _total_add[ret.id] = ret.num;
    //     }
    // }

    // for (let i in _total_add) {
    //     this.updater.add(parseInt(i), _total_add[i]);
    // }
    let bossData = {
        "_id": this.updater.uid + this.updater.time.toString(32),
        "bossID": meteorConfig.bossList[k].bossID,//bossID
        "uid": this.uid,//boss所属玩家
        "startTime": this.updater.time,//开始时间
        "killTime": 0,//击杀时间
        "hp": bossConfig.shareMonsterHP,//血量
        "shareFlag": 0,//分享列表
        "shareList": [this.uid],//分享列表
        "findReward": '',//发现奖励
        "killReward": '',//击杀奖励
        "rewardList": ret,//领取奖励列表
    };
    this.updater.role.set("fWbossID", 0);
    await fWboss.add(this.uid, bossData);
    await this.updater.save();
    return bossData;
}


/**
 * @name getBoss
 * 获取好友boss
 */
exports.getBoss = async function () {
    let fWboss = this.model.mongo('fWboss', this.sid);
    let fWbossData = await fWboss.mget(this.uid) || [];
    let res = [];
    let saveTime = this.config("base", "friendBossRecordingTime").val;
    //对fWbossData里的boss做筛选
    for (let i = 0; i < fWbossData.length; i++) {
        //判断是否过期
        //是否过期
        let bossData = fWbossData[i];
        let bossConfig = this.config("friendBoss", bossData.bossID);
        if (!bossConfig) {
            return this.quick_error("M7GHLB123", '数据配置错误', bossData.bossID);
        }
        if (bossData.startTime + saveTime * 1000 < this.updater.time) {
            continue;
            // return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        }
        //判断有没有领取过这个奖励
        if (bossData.hp <= 0) {
            //击杀奖励是否有领取
        }
        res.push(bossData);
    }
    return res;
}

// /**
//  * @name startFindBattle
//  * @param string bossID bossID
//  * 开始发现战斗
//  **/
// exports.startFindBattle = async function () {
//     let bossID = this.get('bossID', 'string');
//     //去数据库里取出这个boss的数据
//     let fWboss = this.model.mongo('fWboss', this.sid);
//     let bossData = await fWboss.get(this.uid);
//     for (let i = 0; i < bossData.length; i++) {
//         if (bossData[i]._id == bossID) {
//             //判断这个boss的各种状态
//             //是否已被击杀
//             //是否过期
//             //是否已经进入分享二阶段

//         }
//     }

// }

/**
 * @name endFindBattle
 * @param string bossID bossID
 * @param int hp 血量百分比,最大30%
 * 结算第一阶段战斗
 */
exports.endFindBattle = async function () {
    let bossID = this.get('bossID', 'string');
    let hp = this.get('hp', 'int');
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    if (!bossData) {
        return this.quick_error("M7GHLB123", 'err request', bossID);
    }        // for (let i = 0; i < bossData.length; i++) {
    let bossConfig = this.config("friendBoss", bossData.bossID);
    if (!bossConfig) {
        return this.quick_error("M7GHLB123", 'err request', bossData.bossID);
    }
    if (bossData.uid == this.updater.uid) {
        //判断这个boss的各种状态
        //判断这个boss的发现奖励是否领取过了
        if (bossData.findReward != '') {
            return this.quick_error("M7GHLB123", 'err request', bossData.findReward);
        }
        //判断扣除血量是否达标
        if (30 > hp) {
            bossData.hp = (bossData.hp * (100 - hp)) / 100;
        }
        if (30 <= hp) {
            bossData.hp = bossData.hp * 0.3;
            // this.updater.item.add(bossConfig.onhookBoxID, 1);
            for (let i = 0; i < bossData.rewardList.length; i++) {
                this.updater.item.add(bossData.rewardList[i].id, bossData.rewardList[i].num);
            }
        }
        //是否过期，设置10秒的容错时间
        if (bossData.startTime + bossConfig.afkEscapeTime * 1000 + 1000 * 10 < this.updater.time) {
            return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        }
        //是否已被击杀
        if (bossData.hp <= 0) {
            return this.quick_error("M7GHLB123", 'err request', hp);
        }
        //更新血量 最大值只能是30%的血量
        await fWboss.set(bossID, 'hp', bossData.hp);
        await fWboss.set(bossID, 'findReward', this.updater.uid);

        await this.updater.save();
        return bossData;
    }
}

/**
 * @name shareFriend
 * @param string bossID bossID
 * 分享好友
 **/
exports.shareFriend = async function () {
    let bossID = this.get('bossID', 'string');
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    //读出自己所有的好友列表
    let query = { "uid": this.uid, "val": 1 }
    let option = { "multi": true, "dataType": "array", "fields": { "_id": -1, "fid": 1, "bak": 1 } };
    let friend = this.model.mongo("friend", this.sid);
    let friendList = await friend.find(query, option);
    let arrary = [this.updater.uid];
    for (let i = 0; i < friendList.length; i++) {
        arrary.push(friendList[i].fid);
    }

    await fWboss.set(bossData._id, 'shareFlag', 1);
    await fWboss.set(bossData._id, 'shareList', arrary);
    return;
}

/**
 * @name startBattle
 * @param string bossID bossID
 * 开始战斗
 **/
exports.startBattle = async function () {
    let bossID = this.get('bossID', 'string');
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    // for (let i = 0; i < bossDataList.length; i++) {
    //     let bossData = bossDataList[i];
    if (bossData == null) {
        return this.quick_error("M7GHLB123", 'boss 已被击杀', bossID);
    }

    if (bossData._id == bossID) {
        //判断是不是这个bossID的好友或是自己
        if (bossData.uid != this.updater.uid) {
            var flag = false;
            for (let j = 0; j < bossData.shareList.length; j++) {
                if (bossData.shareList[j] == this.updater.uid) {
                    flag = true;
                }
            }
            if (!flag) {
                //不是好友不能打此人的boss
                return this.quick_error("M7GHLB123", '不能打此人的boss', this.updater.uid);
            }
        }
        //判断这个boss的各种状态
        //是否已被击杀
        if (bossData.hp <= 0) {
            return this.quick_error("M7GHLB123", 'boss 已被击杀', bossData.hp);
        }
        //是否过期
        let bossConfig = this.config("friendBoss", bossData.bossID);
        if (!bossConfig) {
            return this.quick_error("M7GHLB123", '数据配置错误', bossData.bossID);
        }
        if (bossData.startTime + bossConfig.challengeTime * 1000 < this.updater.time) {
            return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        }
        //写入redis数据库   
        let fWbossRedis = this.model.redis('fWboss', this.sid);
        await fWbossRedis.set(bossID + ":" + this.updater.uid, this.updater.time)
        return;
    }
    // }
    return this.quick_error("M7GHLB123", 'boss不存在', bossID);
}

/**
 * @name endBattle
 * @param string bossID bossID
 * @param int hp hp
 * @param arrary unitList 战斗阵容
 * 结束战斗
 **/
exports.endBattle = async function () {
    let bossID = this.get('bossID', 'string');
    let hp = this.get('hp', 'int');
    const unitList = this.get('unitList', 'array');
    if (!unitList) {
        return this.quick_error('M2saghge140', ' 参数错误');
    }
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    if (bossData == null) {
        return this.quick_error("M7GHLB123", 'boss 已被击杀', bossID);
    }
    // for (let i = 0; i < bossDataList.length; i++) {
    //     let bossData = bossDataList[i];
    let bossConfig = this.config("friendBoss", bossData.bossID);
    if (!bossConfig) {
        return this.quick_error("M7GHLB123", '表里没找到bossID', bossData.bossID);
    }
    if (bossData._id == bossID) {
        //判断是不是这个bossID的好友或是自己
        this.updater.daily.key("fWboss:" + bossConfig.star);
        await this.updater.data();
        let numLimit = this.updater.daily.get("fWboss:" + bossConfig.star) || 0;
        if (bossData.uid != this.updater.uid) {
            var flag = false;
            for (let j = 0; j < bossData.shareList.length; j++) {
                if (bossData.shareList[j] == this.updater.uid) {
                    flag = true;
                }
            }
            if (!flag) {
                //不是好友不能打此人的boss
                return this.quick_error("M7GHLB123", '不能打此人的boss', this.updater.uid);
            }
        }
        //判断这个boss的各种状态
        //是否已被击杀
        // if (bossData.hp <= 0) {
        //     return this.quick_error("M7GHLB123", 'err request', bossData.hp);
        // }
        //是否过期
        if (bossData.startTime + bossConfig.challengeTime * 1000 < this.updater.time) {
            return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        }
        //写入redis数据库   
        let fWbossRedis = this.model.redis('fWboss', this.sid);
        let redisBattleData = await fWbossRedis.get(bossID + ":" + this.updater.uid);

        // let redisBattleData = await fWbossRedis.get(bossID + ":" + bossID);
        if (redisBattleData + bossConfig.singleBattleTime * 1000 < this.updater.time) {
            return this.quick_error("M7GHLB123", '您真的能结算战斗吗', this.updater.time);
        }
        await fWbossRedis.del(bossID + ":" + this.updater.uid);
        let playerRedisSort = this.model.redis("sort", this.sid, "fWboss_Sort:" + bossID, "fWboss_Sort");
        let data = { "t": this.updater.time, "u": this.uid, "unit": unitList }
        await playerRedisSort.set(JSON.stringify(data), hp);

        if ((bossData.hp - hp) <= 0 && bossData.hp > 0) {
            //击杀
            bossData['killTime'] = this.updater.time;
            await fWboss.set(bossID, "killTime", bossData['killTime']);
        }
        //扣件boss的血量
        // bossData.hp = bossData.hp - hp;
        //判断是否可以领奖励
        let rewardFlag = 0;
        let limitConfig = this.config("friendBossLimit", bossConfig.star);
        if (limitConfig.limit > numLimit) {
            if ((bossData.hp - hp) <= 0 && bossData.hp > 0) {
                //击杀奖励和奖励
                this.updater.item.add(bossConfig.shareBoxID, 1);
                this.updater.item.add(bossConfig.shareBoxID, 1);
                //记录每日领取bōss奖励的次数
                this.updater.daily.add("fWboss:" + bossConfig.star, 1);
                bossData.killReward = this.uid;
                rewardFlag = 1;
                await fWboss.set(bossID, "killReward", this.uid);
            } else if (bossData.hp <= 0) {
                //给奖励
                this.updater.item.add(bossConfig.shareBoxID, 1);
                //记录每日领取bōss奖励的次数
                rewardFlag = 1;
                this.updater.daily.add("fWboss:" + bossConfig.star, 1);
            }
        }
        //更新数据库
        bossData.hp -= hp;
        if (!bossData.hasOwnProperty("battleList")) {
            bossData.battleList = {};
        }
        if (!bossData.battleList.hasOwnProperty(this.uid)) {
            bossData.battleList[this.uid] = {};
        }
        bossData.battleList[this.uid] = { "time": this.updater.time, "flag": rewardFlag }
        await fWboss.set(bossID, "battleList." + this.uid, bossData.battleList[this.uid]);
        await fWboss.set(bossID, "hp", bossData.hp);
        await this.updater.save();
        return bossData;
    }
    // }
    return this.quick_error("M7GHLB123", '未找到boss', bossID);
}


/**
 * @name getReward
 * @param string bossID bossID
 * 获取奖励
 **/
exports.getReward = async function () {
    let bossID = this.get('bossID', 'string');
    let hp = this.get('hp', 'int');
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    if (bossData == null) {
        return this.quick_error("M7GHLB123", 'boss不存在', bossID);
    }
    // for (let i = 0; i < bossDataList.length; i++) {
    // let bossData = bossDataList[i];
    let bossConfig = this.config("friendBoss", bossData.bossID);
    if (!bossConfig) {
        return this.quick_error("M7GHLB123", 'err request', bossData.bossID);
    }
    if (bossData._id == bossID) {
        //判断是不是这个bossID的好友或是自己
        this.updater.daily.key("fWboss:" + bossConfig.star);
        await this.updater.data();
        let numLimit = this.updater.daily.get("fWboss:" + bossConfig.star);
        if (bossData.uid != this.updater.uid) {
            var flag = false;
            for (let j = 0; j < bossData.shareList.length; j++) {
                if (bossData.shareList[j] == this.updater.uid) {
                    flag = true;
                }
            }
            if (!flag) {
                //不是好友不能打此人的boss
                return this.quick_error("M7GHLB123", 'err request', this.updater.uid);
            }
        }
        //判断这个boss的各种状态
        //是否已被击杀
        if (bossData.hp > 0) {
            return this.quick_error("M7GHLB123", 'err request', bossData.hp);
        }
        //是否过期

        // if (bossData.startTime + bossConfig.challengeTime < this.updater.time) {
        //     return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        // }
        //写入redis数据库   
        // let fWbossRedis = this.model.redis('fWboss', this.sid);
        // let redisBattleData = await fWbossRedis.get(bossID + ":" + this.updater.uid);
        // if (redisBattleData + bossConfig.singleBattleTime + 10 < this.updater.time) {
        //     return this.quick_error("M7GHLB123", '怪物已经逃跑了', this.updater.time);
        // }
        // await fWbossRedis.del(bossID + ":" + this.updater.uid);
        //扣件boss的血量
        // bossData.hp = bossData.hp - hp;
        //判断是否可以领奖励
        let limitConfig = this.config("friendBossLimit", bossConfig.star);
        if (limitConfig.limit < numLimit) {
            if (bossData.hp - hp <= 0 && bossData.hp > 0) {
                //击杀奖励
                this.updater.item.add(bossConfig.shareBoxID, 2);
                //记录每日领取bōss奖励的次数
                this.updater.daily.add("fWboss:" + bossConfig.star, 1);
            } else if (bossData.hp <= 0) {
                //给奖励
                this.updater.item.add(bossConfig.shareBoxID, 1);
                //记录每日领取bōss奖励的次数
                this.updater.daily.add("fWboss:" + bossConfig.star, 1);
            }
        } else {
            return this.quick_error("M7GHLB123", 'err request', numLimit);
        }
        // bossData.battleList[this.uid] = { "time": this.updater.time, "flag": flag }
        await fWboss.set(bossID, "battleList." + this.uid + ".flag", 1);
        //更新数据库
        // bossData.hp -= hp;
        // await fWboss.set(bossID, "hp", bossData.hp);
        return await this.updater.save();
        // return bossData;
    }
    // }
    return this.quick_error("M7GHLB123", 'err request', bossID);
}

/**
 * @name getAllReward
 * 一键获取奖励(有风险的功能)
 **/
exports.getAllReward = async function () {
    //拉取所有自己参与过战斗的boss
    let fWboss = this.model.mongo('fWboss', this.sid);
    let fWbossData = await fWboss.mget(this.uid) || [];
    let daily = {};
    let data = [];
    //判断是不是这个bossID的好友或是自己
    for (let i in fWbossData) {
        let bossData = fWbossData[i];
        let bossConfig = this.config("friendBoss", bossData.bossID);
        if (!bossConfig) {
            return this.quick_error("M7GHLB123", 'err request', bossData.bossID);
        }
        if (!daily.hasOwnProperty(bossConfig.star)) {
            this.updater.daily.key("fWboss:" + bossConfig.star);
            await this.updater.data();
            daily[bossConfig.star] = this.updater.daily.get("fWboss:" + bossConfig.star) || 0;
        }
        let numLimit = daily[bossConfig.star];
        if (bossData.uid != this.updater.uid) {
            var flag = false;
            if (bossData.shareList != undefined) {
                for (let j = 0; j < bossData.shareList.length; j++) {
                    if (bossData.shareList[j] == this.updater.uid) {
                        flag = true;
                    }
                }
                if (!flag) {
                    //不是好友不能打此人的boss
                    return this.quick_error("M7GHLB123", 'err request', this.updater.uid);
                }
            }
        }
        //判断这个boss的各种状态
        //是否已被击杀
        if (bossData.hp > 0) {
            //没死
            continue;
        }
        if (!bossData.battleList) {
            continue;
        }
        if (!bossData.battleList.hasOwnProperty(this.uid)) {
            //没参加战斗
            continue;
        }
        //判断是否可以领奖励
        let limitConfig = this.config("friendBossLimit", bossConfig.star);
        if (limitConfig.limit < numLimit) {
            //给奖励
            this.updater.item.add(bossConfig.shareBoxID, 1);
            //记录每日领取bōss奖励的次数
            daily[bossConfig.star]++;
            this.updater.daily.add("fWboss:" + bossConfig.star, 1);
            bossData.battleList[this.uid].flag = 1;
            await fWboss.set(bossID, "battleList." + this.uid + ".flag", 1);
            data.push(bossData);
        } else {
            continue;
        }
    }
    await this.updater.save();
    return data;
}

/**
 * @name delBoss
 * @param string bossID bossID
 * 删除boss
 **/
exports.delBoss = async function () {
    let bossID = this.get('bossID', 'string');
    let hp = this.get('hp', 'int');
    //去数据库里取出这个boss的数据
    let fWboss = this.model.mongo('fWboss', this.sid);
    let bossData = await fWboss.get(bossID);
    // for (let i = 0; i < bossDataList.length; i++) {
    // let bossData = bossDataList[i];
    if (bossData._id == bossID) {
        //判断是不是这个bossID的好友或是自己
        await this.updater.save();
        if (bossData.uid == this.updater.uid) {
            return this.quick_error("M7GHLB123", '不能删除自己发现的boss', this.updater.uid);
        }
        var flag = false;
        for (let j = 0; j < bossData.shareList.length; j++) {
            if (bossData.shareList[j] == this.updater.uid) {
                //删除这个好友
                flag = true;
                bossData.shareList.splice(j, 1);
            }
        }
        if (!flag) {
            //不是好友不能打此人的boss
            return this.quick_error("M7GHLB123", 'err request', this.updater.uid);
        }
    }
    await fWboss.set(bossID, "shareList", bossData.shareList);
    return;
    // }
    return this.quick_error("M7GHLB123", 'err request', bossID);
}


/**
 * @name getRank
 * @param string bossID bossID
 * 获取boss击杀排行榜
 **/
exports.getRank = async function () {
    let bossID = this.get('bossID', 'string');
    let playerRedisSort = this.model.redis("sort", this.sid, "fWboss_Sort:" + bossID, "fWboss_Sort");
    // let data = { "t": this.updater.time, "u": this.uid, "unit": [68001, 68002] }
    // await playerRedisSort.set(JSON.stringify(data), Math.roll(500, 1000));
    return playerRedisSort.range(0, 15, 1).then(ret => {
        return ret;
        // if (!ret || ret.length == 0) {
        //     return result;
        // }
        // let k = 0;
        // for (let i = 0; i < ret.length; i += 2) {
        //     let j = i + 1;
        //     let id = ret[i];
        //     let val = [si + k, Math.floor(ret[j])];
        //     result.order[id] = val;
        //     k++;
        // }
        // return get_user_data.call(this, result);
    })
    // this.updater.role.set("pvp.rank", parseInt(rank));
    // let playerRedisSort2 = this.model.redis("sort", this.sid, "fWboss_Sort:" + bossID, "fWboss_Sort");
    // return playerRedisSort2.get("fWboss_Sort:" + bossID).then((data) => {
    //     console.log(data);
    //     return data;
    // });
    // return rank;
}


/**
 * @name useItem
 * @param int itemID 道具ID
 * 使用道具发现好友boss
 **/
exports.useItem = async function () {
    let itemID = this.get('itemID', 'int');
    //要去判断这个道具是否是发现好友boss的道具
    //读出当前最高关卡的stageID
    // this.updater.role.key('stage');
    // this.updater.role.key('lastHangStage');
    this.updater.daily.key("useBossItem");
    this.updater.role.key('battlePoint');
    await this.updater.data();
    let dailyNum = this.updater.daily.get("useBossItem") || 0;
    //TODO:for test
    if (dailyNum >= 5) {
        return this.quick_error("m2sgrbs1", "每天只能使用5次", dailyNum);
    }
    let battlePoint = this.updater.role.get('battlePoint') || 0;
    let meteorID = 0;
    let starConfig = this.config("meteorGroup");
    if (!starConfig) {
        return this.quick_error("M7GHLB123", 'config_not_exist', "meteorGroup");
    }
    for (let i in starConfig) {
        //判断是否解锁此流星，感觉是bug啊，这样1-1到1-3就不刷流星了诶
        if (starConfig[i].type == 2 && starConfig[i].effectStage <= battlePoint) {
            meteorID = starConfig[i].meteorID;
        }
    }
    // let stageData = this.updater.role.get('stage') || 0;
    //找到最高的通关关卡ID 
    // let lastStage = this.updater.role.get('lastHangStage') || 0;
    // let  = stageData['lastHangStage'];
    // console.log("normal:", stageData['normal']);
    // if (stageData['normal']) {
    //     lastStage = stageData['normal'];
    // }
    // console.log("hard:", stageData['hard']);
    // if (stageData['hard']) {
    //     lastStage = stageData['hard'];
    // }
    // console.log("abyss:", stageData['abyss']);
    // if (stageData['abyss']) {
    //     lastStage = stageData['abyss'];
    // }
    // if (!lastStage) {
    //     return this.quick_error("m2sgrbs1", "挂机数据出错", lastStage);
    // }
    // let stageConfig = this.config("onHookBattle", lastStage);
    // if (!stageConfig) {
    //     return this.quick_error("m2sgrbs1", "数据错误", lastStage);
    // }
    // let meteorID = stageConfig['meteorGroup'];
    // let fWboss = this.model.mongo('fWboss', this.sid);
    //判断是否已经有流星或者还没打的boss
    // if (meteorID != 0) {
    //     return this.quick_error("m2sgrbs1", "数据错误", battlePoint);
    // }
    if (meteorID == 0) {
        return this.quick_error("m2sgrbs1", "数据错误", battlePoint);
    }
    this.updater.role.set("fWbossID", meteorID);
    this.updater.item.sub(itemID, 1);
    this.updater.daily.add("useBossItem", 1);
    return this.updater.save()
}